<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改资料</title>
    <script src="../js/layui/layui.js"></script>
    <link rel="stylesheet" href="../js/layui/css/layui.css"/>
</head>
<body>
<form class="layui-form" id="messageForm" method="post" lay-filter="companyMessageFilter">
    <input type="hidden" name="id" id="id">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">联系人:</label>
            <div class="layui-input-block">
                <input type="text" name="touch" autocomplete="off" placeholder="联系人" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">联系人电话:</label>
            <div class="layui-input-inline">
                <input type="text" name="tel" id="tel" placeholder="联系人电话" autocomplete="off" class="layui-input" onblur="emailYz()">
                <span id="sp"></span>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">邮箱:</label>
            <div class="layui-input-inline">
                <input type="text" name="email" id="email" autocomplete="off" class="layui-input" onblur="emailYz()">
                <span id="sp2"></span>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">联系QQ:</label>
            <div class="layui-input-inline">
                <input type="text" name="touchQq" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">公司地址</label>
            <div class="layui-input-inline">
                <input type="text" name="address" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">行业</label>
            <div class="layui-input-inline">
                <input type="text" name="hangye" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司规模</label>
        <div class="layui-input-block">
            <select name="comguimo">
                <option value="">请选择</option>
                <option value="1">100人以内</option>
                <option value="2">100-200人</option>
                <option value="3">200人以上</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司性质</label>
        <div class="layui-input-block">
            <input type="radio" name="comxingzhi" value="1" title="国企" checked="">
            <input type="radio" name="comxingzhi" value="2" title="私企">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">企业简介:</label>
        <div class="layui-input-block">
            <textarea name="comInfo" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">发展历程:</label>
        <div class="layui-input-block">
            <textarea name="licheng" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
        <input type="hidden" name="comId" id="comId">
    </div>
</form>
</body>
<script>
    var $;
    layui.use(['form', 'layedit', 'laydate'], function() {
        var form = layui.form,
            layer = layui.layer,
            layedit = layui.layedit,
            laydate = layui.laydate;
        $=layui.jquery;
        //日期
        laydate.render({
            elem: '#date',
            type:'datetime'
        });
    })

    function editForm(data) {
        layui.use(['form'], function() {
            var form = layui.form;
            form.val("companyMessageFilter",{
                id:data.id,
                touch:data.touch,
                tel:data.tel,
                email:data.email,
                touchQq:data.touchQq,
                comInfo:data.comInfo,
                comId:data.comId,
                comxingzhi:data.comxingzhi,
                address:data.address,
                hangye:data.hangye,
                comguimo:data.comguimo,
                licheng:data.licheng
            })
        })
    }

    function phone(){
        var msg = document.getElementById("sp");
        var tel = document.getElementById("tel").value;
        var reg = /^(13[0-9]|14[5-9]|15[0-3,5-9]|16[2,5,6,7]|17[0-8]|18[0-9]|19[1,3,5,8,9])\d{8}$/;
        if(reg.test(tel)){
            msg.innerHTML = "<font color='green'>√</font>";
            return true;
        }
        msg.innerHTML = "<font color='red'>请输入正确格式手机号码</font>";
        return false;
    }

    function emailYz(){
        var msg = document.getElementById("sp2");
        var email = document.getElementById("email").value;
        var reg = /^\w{2,}@[a-zA-Z0-9]{2,}\.(com|cn|net)$/;
        if(reg.test(email)){
            msg.innerHTML = "<font color='green'>√</font>";
            return true;
        }else{
            msg.innerHTML = "<font color='red'>邮箱格式是xxxx@xxx.com|cn|net</font>";
            return false;
        }
    }

    function saveCompanyAccountMessage() {
        $.ajax({
            url:'../company/saveCompanyAccountMessage',
            data:$("#messageForm").serialize(),
            type:'post',
            dataType:'json',
            success:function (data) {
                if(!data){
                    layer.alert("修改失败",{icon:0})
                }
            }
        })
    }

</script>
</html>